﻿using System;
using System.Dynamic;

namespace SemanticEx
{
	public class DynamicInvocation : DynamicObject
	{
		#region Constructors

		public DynamicInvocation(Delegate func)
		{
			if (func == null)
			{
				throw new ArgumentNullException("func");
			}
			Delegate = func;
		}

		#endregion

		#region Properties

		private Delegate Delegate { get; set; }

		#endregion

		#region Methods

		public override bool TryInvoke(InvokeBinder binder, object[] args, out object result)
		{
			result = Delegate.DynamicInvoke(args);
			return true;
		}

		#endregion
	}
}